import { ref, watchEffect } from 'vue'

export function useCapsulePosition() {
  const capsuleTop = ref(0)
  const capsuleRight = ref(0)
  const capsuleHeight = ref(0)

  watchEffect(() => {
    const { top, right, height } = uni.getMenuButtonBoundingClientRect()
    capsuleTop.value = top
    capsuleRight.value = right
    capsuleHeight.value = height
  })

  return { capsuleTop, capsuleRight, capsuleHeight }
}
